<template>
	<el-container>
		<el-table :data="orderSubList" current-row-key="id" cell-class-name="discount-table">
			<el-table-column prop="goods_name" label="商品" width="500">
				<template #default="scope">
					<goods-info-item :row="scope.row" :baseUrl="baseUrl" type="order" />
				</template>
			</el-table-column>
			<el-table-column prop="discount" align="center" label="总优惠金额" :formatter="discountFormatter" />
			<el-table-column prop="aa" label="活动优惠信息">
				<template #default="scope">
					<div v-for="(a,index) in scope.row.activitys" :key="index">
						<div>
							活动：{{ a.activityName }}
						</div>
						<div><span style="color: #319809"> - ￥{{ getMoneyByMinute(a.discount) }}</span></div>
					</div>
					<div v-for="(a,index) in scope.row.tuans" :key="index">
						<div>
							团：{{ a.activityName }}
						</div>
						<div><span style="color: #319809"> - ￥{{ getMoneyByMinute(a.discount) }}</span></div>
					</div>
				</template>
			</el-table-column>
			<el-table-column prop="bb" label="优惠券信息">
				<template #default="scope">
					<div v-for="(a,index) in scope.row.coupons" :key="index">
						<div>券：{{ a.couponTitle }}</div>
						<div>
							<span style="color: #319809"> - ￥{{ getMoneyByMinute(a.discount) }}</span>
						</div>
					</div>
				</template>
			</el-table-column>
		</el-table>
	</el-container>
</template>

<script>
export default {
	name: "order-discount-details",
	components: {

	},
	data() {
		return {
			queryId: 0,
			orderSubList: [],
			addressInfo: {},
			baseUrl: ""
		};
	},
	methods: {
		initData(id) {
			console.log(id);
			this.$API.gdshop.attachment.getBaseUrl().then((res) => {
				if (res.code === 0) {
					this.baseUrl = res.data.base_url;
				}
				else {
					this.$message.error('getBaseUrl 失败,' + res.message);
				}
			});
			this.$API.shop.order.discountInfo({ id: id }).then((res) => {
				if (res.code === 0) {
					this.orderSubList = res.data;
				}
				else {
					this.$message.error('discountInfo 失败,' + res.message);
				}
			});
		},
		getMoneyByMinuteAbs(_value) {
			// 取绝对值
			return this.$TOOL.getMoneyByMinute(Math.abs(_value));
		},
		getMoneyByMinute(_value) {
			return this.$TOOL.getMoneyByMinute(_value);
		},
		discountFormatter(row,col,val) {
			return '￥' + this.getMoneyByMinute(val);
		}
	}
};
</script>

<style lang="scss" scoped>
.discount-table{
	color: #F00;
}
</style>
